package chixing.day20.proxy.homework.work4;

import java.util.List;
import java.util.Map;

public class Test {
    public static void main(String[] args) {
        Contract contract1 = new Contract("001", "三星", "材料部门", 5000, Status.DRAFT);
        Contract contract2 = new Contract("002", "小米", "技术部门", 1000, Status.DRAFT);
        Contract contract3 = new Contract("003", "华为", "后勤部门", 9000, Status.DRAFT);
        Contract contract4 = new Contract("004", "三星", "财务部门", 3000, Status.DRAFT);
        Contract contract5 = new Contract("005", "华为", "技术部门", 2000, Status.DRAFT);
        Contract contract6 = new Contract("006", "华硕", "后勤部门", 8000, Status.DRAFT);

        ContractService.add(contract1);
        ContractService.add(contract2);
        ContractService.add(contract3);
        ContractService.add(contract4);
        ContractService.add(contract5);
        ContractService.add(contract6);


        ContractService contractService = new ContractService();
        contractService.submitForApproval(contract1.getContractId());
        contractService.approve(contract2.getContractId());
        contractService.reject(contract3.getContractId());
        contractService.approve(contract4.getContractId());
        contractService.approve(contract5.getContractId());
        contractService.approve(contract6.getContractId());

        List<Contract> contractsByStatus = contractService.getContractsByStatus(Status.APPROVED);
        System.out.println("状态为 APPROVED  的合同");
        contractsByStatus.forEach(System.out::println);

        double v = contractService.totalAmountByDepartment("技术部门");
        System.out.println("技术部门合通总金额："+v);

        Map<String, List<String>> stringListMap = contractService.groupBySupplier();
        System.out.print("按供应商分组合同:");
        for (Map.Entry<String,List<String>> e:stringListMap.entrySet()) {
            System.out.print("供应商"+e.getKey()+"->"+e.getValue()+",");
        }
    }
}
